##Replication codes for figures and tables in the main appendix of 
#"Unmasking the rule of law: crime, punishment, and partisanship in comparative perspective"

#Note: use R version 4.1.0

#######################0. preparation for replication
#1)load packages
library(haven)
library(labelled)
library(ggplot2)

#2)load data
ugov_GE <- read_dta("germany_data_ejpr.dta")
ugov_HU <- read_dta("hungary_data_ejpr.dta")
ugov_PL <- read_dta("poland_data_ejpr.dta")
ugov_us_merged <- read_dta("us_data_ejpr.dta")

#3)generate functions to be used
#handy function for 95% CI (http://www.cookbook-r.com/Manipulating_data/Summarizing_data/)

summarySE <- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE,
                      conf.interval=.95, .drop=TRUE) {
  library(plyr)
  
  # New version of length which can handle NA's: if na.rm==T, don't count them
  length2 <- function (x, na.rm=FALSE) {
    if (na.rm) sum(!is.na(x))
    else       length(x)
  }
  
  # This does the summary. For each group's data frame, return a vector with
  # N, mean, and sd
  datac <- ddply(data, groupvars, .drop=.drop,
                 .fun = function(xx, col) {
                   c(N    = length2(xx[[col]], na.rm=na.rm),
                     mean = mean   (xx[[col]], na.rm=na.rm),
                     sd   = sd     (xx[[col]], na.rm=na.rm)
                   )
                 },
                 measurevar
  )
  
  # Rename the "mean" column    
  datac <- rename(datac, c("mean" = measurevar))
  
  datac$se <- datac$sd / sqrt(datac$N)  # Calculate standard error of the mean
  
  # Confidence interval multiplier for standard error
  # Calculate t-statistic for confidence interval: 
  # e.g., if conf.interval is .95, use .975 (above/below), and use df=N-1
  ciMult <- qt(conf.interval/2 + .5, datac$N-1)
  datac$ci <- datac$se * ciMult
  
  return(datac)
}

#and t-test with summary statistics
t.test2 <- function(m1,m2,s1,s2,n1,n2,m0=0,equal.variance=FALSE)
{
  if( equal.variance==FALSE ) 
  {
    se <- sqrt( (s1^2/n1) + (s2^2/n2) )
    # welch-satterthwaite df
    df <- ( (s1^2/n1 + s2^2/n2)^2 )/( (s1^2/n1)^2/(n1-1) + (s2^2/n2)^2/(n2-1) )
  } else
  {
    # pooled standard deviation, scaled by the sample sizes
    se <- sqrt( (1/n1 + 1/n2) * ((n1-1)*s1^2 + (n2-1)*s2^2)/(n1+n2-2) ) 
    df <- n1+n2-2
  }      
  t <- (m1-m2-m0)/se 
  dat <- c(m1-m2, se, t, 2*pt(-abs(t),df))    
  names(dat) <- c("Difference of means", "Std Error", "t", "p-value")
  return(dat) 
}

#######################Replicating figures and tables in the main appendix
####Create data objects again now with 'someone' and 'public servant' treatment that are mainly used in the Appendix
#1) Germany
#subsetting relevant population
a<-ugov_GE[which(ugov_GE$treat_1_w2==4),]
b<-ugov_GE[which(ugov_GE$treat_1_w2==5),]
c<-ugov_GE[which(ugov_GE$treat_1_w2==6),]
d<-ugov_GE[which(ugov_GE$treat_1_w2==1),]
ge_dat_plot<-as.data.frame(rbind(a,b,c,d))
rm(a)
rm(b)
rm(c)
rm(d)
#omitting nas
ge_dat_plot<-ge_dat_plot[!is.na(ge_dat_plot$treat_1_2_w2),]
ge_dat_plot<-ge_dat_plot[!is.na(ge_dat_plot$treat_1_w2),]
ge_dat_plot<-ge_dat_plot[!is.na(ge_dat_plot$fine_support_w2),]
ge_dat_plot<-ge_dat_plot[!is.na(ge_dat_plot$fine_amount_w2),]
#creating covid_convern varaible
ge_dat_plot$covid_concern<-NA
ge_dat_plot$covid_concern[which(ge_dat_plot$cvfeelings_w2==1)]<-1
ge_dat_plot$covid_concern[which(ge_dat_plot$cvfeelings_w2==2)]<-1
ge_dat_plot$covid_concern[which(ge_dat_plot$cvfeelings_w2==3)]<-0
ge_dat_plot$covid_concern[which(ge_dat_plot$cvfeelings_w2==4)]<-0
ge_dat_plot<-ge_dat_plot[!is.na(ge_dat_plot$covid_concern),]

#rescaling the dv
ge_dat_plot$fine_support_w2<-5-ge_dat_plot$fine_support_w2
ge_dat_plot$treat_1_w2<-as.factor(ge_dat_plot$treat_1_w2)
ge_dat_plot$treat_1_2_w2<-as.factor(ge_dat_plot$treat_1_2_w2)
ge_dat_plot$covid_concern<-as.factor(ge_dat_plot$covid_concern)
a=which(ge_dat_plot$treat_1_2_w2==1)
b=which(ge_dat_plot$treat_1_2_w2==2)
ge_dat_plot$treat_1_2_w2[a]<-2
ge_dat_plot$treat_1_2_w2[b]<-1

#omitting NAs
ge_dat_plot<-ge_dat_plot[!is.na(ge_dat_plot$fine_amount_w2),]

#generate fine dollars, the variable that normalize the currency as the value of dollar
ge_dat_plot$fine_amount_w2_dollars<-ge_dat_plot$fine_amount_w2*1.12

#2) Hungary
#making binary concern variable
ugov_HU$covid_concern<-NA
ugov_HU$covid_concern[which(ugov_HU$yougov_cv_feel==1)]<-1
ugov_HU$covid_concern[which(ugov_HU$yougov_cv_feel==2)]<-1
ugov_HU$covid_concern[which(ugov_HU$yougov_cv_feel==3)]<-0
ugov_HU$covid_concern[which(ugov_HU$yougov_cv_feel==4)]<-0

#subset data that are only needed with creating types and fine binary variables

#subsetting fined civil servant
f_cs<-ugov_HU[which(ugov_HU$mask_1_treatment==4&ugov_HU$mask_2_treatment==1),] 
f_cs$fine_bin<-1
f_cs$type<-1
#subsetting not fined civil servant
nf_cs<-ugov_HU[which(ugov_HU$mask_1_treatment==4&ugov_HU$mask_2_treatment==2),]
nf_cs$fine_bin<-0
nf_cs$type<-1
#subsetting fined most-liked MP
a<-ugov_HU[which(ugov_HU$most_liked_party_HU==1&ugov_HU$mask_1_treatment==2&ugov_HU$mask_2_treatment==1),]
b<-ugov_HU[which(ugov_HU$most_liked_party_HU==2&ugov_HU$mask_1_treatment==3&ugov_HU$mask_2_treatment==1),]
f_ml<-rbind(a,b)
f_ml$fine_bin<-1
f_ml$type<-2
#subsetting not fined most-liked MP
a<-ugov_HU[which(ugov_HU$most_liked_party_HU==1&ugov_HU$mask_1_treatment==2&ugov_HU$mask_2_treatment==2),]
b<-ugov_HU[which(ugov_HU$most_liked_party_HU==2&ugov_HU$mask_1_treatment==3&ugov_HU$mask_2_treatment==2),]
nf_ml<-rbind(a,b)
nf_ml$fine_bin<-0
nf_ml$type<-2
#subsetting fined least-liked MP
a<-ugov_HU[which(ugov_HU$most_liked_party_HU==1&ugov_HU$mask_1_treatment==3&ugov_HU$mask_2_treatment==1),]
b<-ugov_HU[which(ugov_HU$most_liked_party_HU==2&ugov_HU$mask_1_treatment==2&ugov_HU$mask_2_treatment==1),]
c<-ugov_HU[which(ugov_HU$most_liked_party_HU==9&ugov_HU$mask_1_treatment==2&ugov_HU$mask_2_treatment==1),]
d<-ugov_HU[which(ugov_HU$most_liked_party_HU==9&ugov_HU$mask_1_treatment==3&ugov_HU$mask_2_treatment==1),]
f_ll<-rbind(a,b,c,d)
f_ll$fine_bin<-1
f_ll$type<-3
#subsetting not fined least-liked MP
a<-ugov_HU[which(ugov_HU$most_liked_party_HU==1&ugov_HU$mask_1_treatment==3&ugov_HU$mask_2_treatment==2),]
b<-ugov_HU[which(ugov_HU$most_liked_party_HU==2&ugov_HU$mask_1_treatment==2&ugov_HU$mask_2_treatment==2),]
c<-ugov_HU[which(ugov_HU$most_liked_party_HU==9&ugov_HU$mask_1_treatment==2&ugov_HU$mask_2_treatment==2),]
d<-ugov_HU[which(ugov_HU$most_liked_party_HU==9&ugov_HU$mask_1_treatment==3&ugov_HU$mask_2_treatment==2),]
nf_ll<-rbind(a,b,c,d)
nf_ll$fine_bin<-0
nf_ll$type<-3
#subsetting fined someone
f_so<-ugov_HU[which(ugov_HU$mask_1_treatment==1&ugov_HU$mask_2_treatment==1),]
f_so$fine_bin<-1
f_so$type<-0
#subsetting not fined someone
nf_so<-ugov_HU[which(ugov_HU$mask_1_treatment==1&ugov_HU$mask_2_treatment==2),]
nf_so$fine_bin<-0
nf_so$type<-0

#aggregate all the created objects 
hu_dat_plot<-rbind(f_cs,f_ll,f_ml,nf_cs,nf_ll,nf_ml,f_so,nf_so)
hu_dat_plot$fine_bin<-as.factor(hu_dat_plot$fine_bin) #make the fine binary variable as a factor
hu_dat_plot$type<-as.factor(hu_dat_plot$type) #make the type variable as a factor
hu_dat_plot$covid_concern<-as.factor(hu_dat_plot$covid_concern) #make covid concern variable as a factor
hu_dat_plot<-hu_dat_plot[!is.na(hu_dat_plot$mask_fine),] #omit NAs in dependent varaible

#make fine amount appropriate for the value of Hungarian currency
hu_dat_plot$mask_fine<-hu_dat_plot$mask_fine*1000

#generate fine dollars, the variable that normalize the currency as the value of dollar
hu_dat_plot$mask_fine_dollars<-hu_dat_plot$mask_fine*0.0034

#3) US

#create partisanship variable
ugov_us_merged$most_liked_party<-NA
ugov_us_merged$most_liked_party[which(ugov_us_merged$pid7==1)]<-1 
ugov_us_merged$most_liked_party[which(ugov_us_merged$pid7==2)]<-1 
ugov_us_merged$most_liked_party[which(ugov_us_merged$pid7==3)]<-1 #dem
ugov_us_merged$most_liked_party[which(ugov_us_merged$pid7==5)]<-2
ugov_us_merged$most_liked_party[which(ugov_us_merged$pid7==6)]<-2 
ugov_us_merged$most_liked_party[which(ugov_us_merged$pid7==7)]<-2 #rep
ugov_us_merged$most_liked_party[which(ugov_us_merged$pid7==4)]<-3 #ind

#making binary concern variable
ugov_us_merged$covid_concern<-NA
ugov_us_merged$covid_concern[which(ugov_us_merged$yougov_cv_feel==1)]<-1
ugov_us_merged$covid_concern[which(ugov_us_merged$yougov_cv_feel==2)]<-1
ugov_us_merged$covid_concern[which(ugov_us_merged$yougov_cv_feel==3)]<-0
ugov_us_merged$covid_concern[which(ugov_us_merged$yougov_cv_feel==4)]<-0

#subset data that are only needed with creating types and fine binary variables

#subsetting fined civil servant
f_cs<-ugov_us_merged[which(ugov_us_merged$mask_1_treatment==4&ugov_us_merged$mask_2_treatment==1),]
f_cs$fine_bin<-1
f_cs$type<-1
#subsetting not fined civil servant
nf_cs<-ugov_us_merged[which(ugov_us_merged$mask_1_treatment==4&ugov_us_merged$mask_2_treatment==2),]
nf_cs$fine_bin<-0
nf_cs$type<-1
#subsetting fined most-liked MP
a<-ugov_us_merged[which(ugov_us_merged$most_liked_party==1&ugov_us_merged$mask_1_treatment==2&ugov_us_merged$mask_2_treatment==1),]
b<-ugov_us_merged[which(ugov_us_merged$most_liked_party==2&ugov_us_merged$mask_1_treatment==3&ugov_us_merged$mask_2_treatment==1),]
f_ml<-rbind(a,b)
f_ml$fine_bin<-1
f_ml$type<-2
#subsetting not fined most-liked MP
a<-ugov_us_merged[which(ugov_us_merged$most_liked_party==1&ugov_us_merged$mask_1_treatment==2&ugov_us_merged$mask_2_treatment==2),]
b<-ugov_us_merged[which(ugov_us_merged$most_liked_party==2&ugov_us_merged$mask_1_treatment==3&ugov_us_merged$mask_2_treatment==2),]
nf_ml<-rbind(a,b)
nf_ml$fine_bin<-0
nf_ml$type<-2
#subsetting fined least-liked MP
a<-ugov_us_merged[which(ugov_us_merged$most_liked_party==1&ugov_us_merged$mask_1_treatment==3&ugov_us_merged$mask_2_treatment==1),]
b<-ugov_us_merged[which(ugov_us_merged$most_liked_party==2&ugov_us_merged$mask_1_treatment==2&ugov_us_merged$mask_2_treatment==1),]
c<-ugov_us_merged[which(ugov_us_merged$most_liked_party==3&ugov_us_merged$mask_1_treatment==2&ugov_us_merged$mask_2_treatment==1),]
d<-ugov_us_merged[which(ugov_us_merged$most_liked_party==3&ugov_us_merged$mask_1_treatment==3&ugov_us_merged$mask_2_treatment==1),]
f_ll<-rbind(a,b,c,d)
f_ll$fine_bin<-1
f_ll$type<-3
#subsetting not fined least-liked MP
a<-ugov_us_merged[which(ugov_us_merged$most_liked_party==1&ugov_us_merged$mask_1_treatment==3&ugov_us_merged$mask_2_treatment==2),]
b<-ugov_us_merged[which(ugov_us_merged$most_liked_party==2&ugov_us_merged$mask_1_treatment==2&ugov_us_merged$mask_2_treatment==2),]
c<-ugov_us_merged[which(ugov_us_merged$most_liked_party==3&ugov_us_merged$mask_1_treatment==2&ugov_us_merged$mask_2_treatment==2),]
d<-ugov_us_merged[which(ugov_us_merged$most_liked_party==3&ugov_us_merged$mask_1_treatment==3&ugov_us_merged$mask_2_treatment==2),]
nf_ll<-rbind(a,b,c,d)
nf_ll$fine_bin<-0
nf_ll$type<-3
#subsetting fined someone
f_so<-ugov_us_merged[which(ugov_us_merged$mask_1_treatment==1&ugov_us_merged$mask_2_treatment==1),]
f_so$fine_bin<-1
f_so$type<-0
#subsetting not fined someone
nf_so<-ugov_us_merged[which(ugov_us_merged$mask_1_treatment==1&ugov_us_merged$mask_2_treatment==2),]
nf_so$fine_bin<-0
nf_so$type<-0

#aggregate all the created objects 
us_dat_plot<-rbind(f_cs,f_ll,f_ml,nf_cs,nf_ll,nf_ml,f_so,nf_so)
us_dat_plot$fine_bin<-as.factor(us_dat_plot$fine_bin) #make the fine binary variable as a factor
us_dat_plot$type<-as.factor(us_dat_plot$type) #make the treatement type variable as a factor 
us_dat_plot$covid_concern<-as.factor(us_dat_plot$covid_concern) #make the covid concern variable as a factor
us_dat_plot<-us_dat_plot[!is.na(us_dat_plot$mask_fine),] #omit NAs in dependent variable

#4) Poland

#making binary concern variable
ugov_PL$covid_concern<-NA
ugov_PL$covid_concern[which(ugov_PL$yougov_cv_feel==1)]<-1
ugov_PL$covid_concern[which(ugov_PL$yougov_cv_feel==2)]<-1
ugov_PL$covid_concern[which(ugov_PL$yougov_cv_feel==3)]<-0
ugov_PL$covid_concern[which(ugov_PL$yougov_cv_feel==4)]<-0
ugov_PL$covid_concern[which(ugov_PL$yougov_cv_feel==5)]<-0

#subset data that are only needed with creating types and fine binary variables

#subsetting fined civil servant
f_cs<-ugov_PL[which(ugov_PL$mask_1_treatment==4&ugov_PL$mask_2_treatment==1),]
f_cs$fine_bin<-1
f_cs$type<-1
#subsetting not fined civil servant
nf_cs<-ugov_PL[which(ugov_PL$mask_1_treatment==4&ugov_PL$mask_2_treatment==2),]
nf_cs$fine_bin<-0
nf_cs$type<-1
#subsetting fined most-liked MP
a<-ugov_PL[which(ugov_PL$party_pick==1&ugov_PL$mask_1_treatment==2&ugov_PL$mask_2_treatment==1),]
b<-ugov_PL[which(ugov_PL$party_pick==2&ugov_PL$mask_1_treatment==3&ugov_PL$mask_2_treatment==1),]
f_ml<-rbind(a,b)
f_ml$fine_bin<-1
f_ml$type<-2
#subsetting not fined most-liked MP
a<-ugov_PL[which(ugov_PL$party_pick==1&ugov_PL$mask_1_treatment==2&ugov_PL$mask_2_treatment==2),]
b<-ugov_PL[which(ugov_PL$party_pick==2&ugov_PL$mask_1_treatment==3&ugov_PL$mask_2_treatment==2),]
nf_ml<-rbind(a,b)
nf_ml$fine_bin<-0
nf_ml$type<-2
#subsetting fined least-liked MP
a<-ugov_PL[which(ugov_PL$party_pick==1&ugov_PL$mask_1_treatment==3&ugov_PL$mask_2_treatment==1),]
b<-ugov_PL[which(ugov_PL$party_pick==2&ugov_PL$mask_1_treatment==2&ugov_PL$mask_2_treatment==1),]
f_ll<-rbind(a,b)
f_ll$fine_bin<-1
f_ll$type<-3
#subsetting not fined least-liked MP
a<-ugov_PL[which(ugov_PL$party_pick==1&ugov_PL$mask_1_treatment==3&ugov_PL$mask_2_treatment==2),]
b<-ugov_PL[which(ugov_PL$party_pick==2&ugov_PL$mask_1_treatment==2&ugov_PL$mask_2_treatment==2),]
nf_ll<-rbind(a,b)
nf_ll$fine_bin<-0
nf_ll$type<-3
#subsetting fined someone
f_so<-ugov_PL[which(ugov_PL$mask_1_treatment==1&ugov_PL$mask_2_treatment==1),]
f_so$fine_bin<-1
f_so$type<-0
#subsetting not fined someone
nf_so<-ugov_PL[which(ugov_PL$mask_1_treatment==1&ugov_PL$mask_2_treatment==2),]
nf_so$fine_bin<-0
nf_so$type<-0

#aggregate all the created objects 
pl_dat_plot<-rbind(f_cs,f_ll,f_ml,nf_cs,nf_ll,nf_ml,f_so,nf_so)
pl_dat_plot$fine_bin<-as.factor(pl_dat_plot$fine_bin) #make the fine binary variable as a factor
pl_dat_plot$type<-as.factor(pl_dat_plot$type) #make the treatement type variable as a factor 
pl_dat_plot$covid_concern<-as.factor(pl_dat_plot$covid_concern) #make the covid concern variable as a factor
pl_dat_plot<-pl_dat_plot[!is.na(pl_dat_plot$mask_fine),] #omit NAs in dependent variable

#make fine amount appropriate for the value of Polish currency
pl_dat_plot$mask_fine<-pl_dat_plot$mask_fine*10

#generate fine dollars, the variable that normalize the currency as the value of dollar
pl_dat_plot$mask_fine_dollars<-pl_dat_plot$mask_fine*0.26

#remove all unnecessary objects
rm(a,b,c,d,f_cs,f_ll,f_ml,nf_cs,nf_ll,nf_ml,f_so,nf_so)

####Table A1.

####Figure A1. in main_replication.R
#This is the table of frequencies for the most/least liked parties.

####Figure B1
pdf("figureB1.pdf")
par(mfrow = c(2,2))
hist(ge_dat_plot$fine_amount_w2_dollars, main="Germany", xlab="Fine amount (Dollar)")
hist(us_dat_plot$mask_fine, main="US", xlab="Fine amount (Dollar)")
hist(hu_dat_plot$mask_fine_dollars, main="Hungary", xlab="Fine amount (Dollar)")
hist(pl_dat_plot$mask_fine_dollars, main="Poland", xlab="Fine amount (Dollar)")
dev.off()

####Figure B2: Fine Imposed by Shopper Treatment

figureB2<-vector(mode="list",length=4)

ge_app_2 <- summarySE(ge_dat_plot, measurevar="fine_amount_w2_dollars", groupvars=c("treat_1_w2"))

figureB2[[1]]<-ggplot(ge_app_2, aes(x=treat_1_w2, y=fine_amount_w2_dollars)) + 
  geom_errorbar(aes(ymin=fine_amount_w2_dollars-ci, ymax=fine_amount_w2_dollars+ci), width=.1) +
  geom_line() +
  geom_point()+
  ylim(140,500)+
  scale_x_discrete(name =" ", 
                   labels=c("1" = "Someone","4" = "Senior Civil Servant", "5" = "Most-Liked MP",
                            "6" = "Least-Liked MP"))+
  labs(y="Fine Amount (Dollar)",title = "Germany")+
  theme_bw()+
  theme(plot.title = element_text(hjust = 0.5))

hu_app_2 <- summarySE(hu_dat_plot, measurevar="mask_fine_dollars", groupvars=c("type"))

figureB2[[2]]<-ggplot(hu_app_2, aes(x=type, y=mask_fine_dollars)) + 
  geom_errorbar(aes(ymin=mask_fine_dollars-ci, ymax=mask_fine_dollars+ci), width=.1) +
  geom_line() +
  geom_point()+
  ylim(140,500)+
  scale_x_discrete(name =" ", 
                   labels=c("0" = "Someone","1" = "Senior Civil Servant", "2" = "Most-Liked MP",
                            "3" = "Least-Liked MP"))+
  labs(y="Fine Amount (Dollar)",title = "Hungary")+
  theme_bw()+
  theme(plot.title = element_text(hjust = 0.5))

us_app_2<-summarySE(us_dat_plot, measurevar="mask_fine", groupvars=c("type"))

figureB2[[3]]<-ggplot(us_app_2, aes(x=type, y=mask_fine)) + 
  geom_errorbar(aes(ymin=mask_fine-ci, ymax=mask_fine+ci), width=.1) +
  geom_line() +
  geom_point()+
  ylim(140,500)+
  scale_x_discrete(name =" ", 
                   labels=c("0" = "Someone","1" = "Senior Civil Servant", "2" = "Most-Liked MP",
                            "3" = "Least-Liked MP"))+
  labs(y="Fine Amount (Dollar)",title = "The United States")+
  theme_bw()+
  theme(plot.title = element_text(hjust = 0.5))

pl_app_2<-summarySE(pl_dat_plot, measurevar="mask_fine_dollars", groupvars=c("type"))

figureB2[[4]]<-ggplot(pl_app_2, aes(x=type, y=mask_fine_dollars)) + 
  geom_errorbar(aes(ymin=mask_fine_dollars-ci, ymax=mask_fine_dollars+ci), width=.1) +
  geom_line() +
  geom_point()+
  ylim(140,500)+
  scale_x_discrete(name =" ", 
                   labels=c("0" = "Someone","1" = "Senior Civil Servant", "2" = "Most-Liked MP",
                            "3" = "Least-Liked MP"))+
  labs(y="Fine Amount (Dollar)",title = "Poland")+
  theme_bw()+
  theme(plot.title = element_text(hjust = 0.5))

ggsave("figureB2.pdf", width=10, height=10,gridExtra::marrangeGrob(grobs = figureB2, nrow=2, ncol=2,top=NULL))

####Figure B3: Fine Imposed by Shopper Treatment and Covid-19 Concern
figureB3<-vector(mode="list",length=4)

ge_app_3 <- summarySE(ge_dat_plot, measurevar="fine_amount_w2_dollars", groupvars=c("treat_1_w2","covid_concern"))
ge_app_3 <-na.omit(ge_app_3)
pd <- position_dodge(0.3)

figureB3[[1]]<-ggplot(ge_app_3, aes(x=treat_1_w2, y=fine_amount_w2_dollars, colour=covid_concern)) + 
  geom_errorbar(aes(ymin=fine_amount_w2_dollars-ci, ymax=fine_amount_w2_dollars+ci), width=.1,position=pd) +
  geom_line(position = pd) +
  geom_point(position = pd)+
  ylim(100,500)+
  scale_x_discrete(name =" ", 
                   labels=c("1" = "Someone","4" = "Senior Civil Servant", "5" = "Most-Liked MP",
                            "6" = "Least-Liked MP"))+
  scale_colour_manual(name="Covid Concern",    # Legend label, use darker colors
                      breaks=c("0", "1"),
                      labels=c("Not Worried", "Worried"),
                      values = c("grey50","black"))+
  labs(y="Fine Amount (Dollar)",title = "Germany")+
  theme_bw()+
  theme(plot.title = element_text(hjust = 0.5),legend.position = "none")

hu_app_3 <- summarySE(hu_dat_plot, measurevar="mask_fine_dollars", groupvars=c("type","covid_concern"))
hu_app_3 <-na.omit(hu_app_3)
pd <- position_dodge(0.3)

figureB3[[2]]<-ggplot(hu_app_3, aes(x=type, y=mask_fine_dollars, colour=covid_concern)) + 
  geom_errorbar(aes(ymin=mask_fine_dollars-ci, ymax=mask_fine_dollars+ci), width=.1,position=pd) +
  geom_line(position = pd) +
  geom_point(position = pd)+
  ylim(100,500)+
  scale_x_discrete(name =" ", 
                   labels=c("0" = "Someone","1" = "Senior Civil Servant", "2" = "Most-Liked MP",
                            "3" = "Least-Liked MP"))+
  scale_colour_manual(name="Covid Concern",    # Legend label, use darker colors
                      breaks=c("0", "1"),
                      labels=c("Not Worried", "Worried"),
                      values = c("grey50","black"))+
  labs(y="Fine Amount (Dollar)",title = "Hungary")+
  theme_bw()+
  theme(plot.title = element_text(hjust = 0.5),legend.position = "none")

us_app_3 <- summarySE(us_dat_plot, measurevar="mask_fine", groupvars=c("type","covid_concern"))
us_app_3 <-na.omit(us_app_3)
pd <- position_dodge(0.3)

figureB3[[3]]<-ggplot(us_app_3, aes(x=type, y=mask_fine, colour=covid_concern)) + 
  geom_errorbar(aes(ymin=mask_fine-ci, ymax=mask_fine+ci), width=.1,position=pd) +
  geom_line(position = pd) +
  geom_point(position = pd)+
  ylim(100,500)+
  scale_x_discrete(name =" ", 
                   labels=c("0" = "Someone","1" = "Senior Civil Servant", "2" = "Most-Liked MP",
                            "3" = "Least-Liked MP"))+
  scale_colour_manual(name="Covid Concern",    # Legend label, use darker colors
                      breaks=c("0", "1"),
                      labels=c("Not Worried", "Worried"),
                      values = c("grey50","black"))+
  labs(y="Fine Amount (Dollar)",title = "The United States")+
  theme_bw()+
  theme(plot.title = element_text(hjust = 0.5),legend.position = "none")

pl_app_3 <- summarySE(pl_dat_plot, measurevar="mask_fine_dollars", groupvars=c("type","covid_concern"))
pl_app_3 <-na.omit(pl_app_3)
pd <- position_dodge(0.3)

figureB3[[4]]<-ggplot(pl_app_3, aes(x=type, y=mask_fine_dollars, colour=covid_concern)) + 
  geom_errorbar(aes(ymin=mask_fine_dollars-ci, ymax=mask_fine_dollars+ci), width=.1,position=pd) +
  geom_line(position = pd) +
  geom_point(position = pd)+
  ylim(100,500)+
  scale_x_discrete(name =" ", 
                   labels=c("0" = "Someone","1" = "Senior Civil Servant", "2" = "Most-Liked MP",
                            "3" = "Least-Liked MP"))+
  scale_colour_manual(name="Covid Concern",    # Legend label, use darker colors
                      breaks=c("0", "1"),
                      labels=c("Not Worried", "Worried"),
                      values = c("grey50","black"))+
  labs(y="Fine Amount (Dollar)",title = "Poland")+
  theme_bw()+
  theme(plot.title = element_text(hjust = 0.5),legend.position = c(0.80, 0.25))

ggsave("figureB3.pdf", width=10, height=10,gridExtra::marrangeGrob(grobs = figureB3, nrow=2, ncol=2,top=NULL))

####Table B1. Figure B2 t-test results(dollar adjusted)
options(scipen = 40)
ge_app_2_d <- summarySE(ge_dat_plot, measurevar="fine_amount_w2_dollars", groupvars=c("treat_1_w2"))
t.test2(ge_app_2_d$fine_amount_w2[1],ge_app_2_d$fine_amount_w2[2],ge_app_2_d$sd[1],ge_app_2_d$sd[2],ge_app_2_d$N[1],ge_app_2_d$N[2])
t.test2(ge_app_2_d$fine_amount_w2[1],ge_app_2_d$fine_amount_w2[3],ge_app_2_d$sd[1],ge_app_2_d$sd[3],ge_app_2_d$N[1],ge_app_2_d$N[3])
t.test2(ge_app_2_d$fine_amount_w2[1],ge_app_2_d$fine_amount_w2[4],ge_app_2_d$sd[1],ge_app_2_d$sd[4],ge_app_2_d$N[1],ge_app_2_d$N[4])
t.test2(ge_app_2_d$fine_amount_w2[2],ge_app_2_d$fine_amount_w2[3],ge_app_2_d$sd[2],ge_app_2_d$sd[3],ge_app_2_d$N[2],ge_app_2_d$N[3])
t.test2(ge_app_2_d$fine_amount_w2[2],ge_app_2_d$fine_amount_w2[4],ge_app_2_d$sd[2],ge_app_2_d$sd[4],ge_app_2_d$N[2],ge_app_2_d$N[4])
t.test2(ge_app_2_d$fine_amount_w2[3],ge_app_2_d$fine_amount_w2[4],ge_app_2_d$sd[3],ge_app_2_d$sd[4],ge_app_2_d$N[3],ge_app_2_d$N[4])

us_app_2<-summarySE(us_dat_plot, measurevar="mask_fine", groupvars=c("type"))
t.test2(us_app_2$mask_fine[1],us_app_2$mask_fine[2],us_app_2$sd[1],us_app_2$sd[2],us_app_2$N[1],us_app_2$N[2])
t.test2(us_app_2$mask_fine[1],us_app_2$mask_fine[3],us_app_2$sd[1],us_app_2$sd[3],us_app_2$N[1],us_app_2$N[3])
t.test2(us_app_2$mask_fine[1],us_app_2$mask_fine[4],us_app_2$sd[1],us_app_2$sd[4],us_app_2$N[1],us_app_2$N[4])
t.test2(us_app_2$mask_fine[2],us_app_2$mask_fine[3],us_app_2$sd[2],us_app_2$sd[3],us_app_2$N[2],us_app_2$N[3])
t.test2(us_app_2$mask_fine[2],us_app_2$mask_fine[4],us_app_2$sd[2],us_app_2$sd[4],us_app_2$N[2],us_app_2$N[4])
t.test2(us_app_2$mask_fine[3],us_app_2$mask_fine[4],us_app_2$sd[3],us_app_2$sd[4],us_app_2$N[3],us_app_2$N[4])

hu_app_2_d <- summarySE(hu_dat_plot, measurevar="mask_fine_dollars", groupvars=c("type"))
t.test2(hu_app_2_d$mask_fine_dollars[1],hu_app_2_d$mask_fine_dollars[2],hu_app_2_d$sd[1],hu_app_2_d$sd[2],hu_app_2_d$N[1],hu_app_2_d$N[2])
t.test2(hu_app_2_d$mask_fine_dollars[1],hu_app_2_d$mask_fine_dollars[3],hu_app_2_d$sd[1],hu_app_2_d$sd[3],hu_app_2_d$N[1],hu_app_2_d$N[3])
t.test2(hu_app_2_d$mask_fine_dollars[1],hu_app_2_d$mask_fine_dollars[4],hu_app_2_d$sd[1],hu_app_2_d$sd[4],hu_app_2_d$N[1],hu_app_2_d$N[4])
t.test2(hu_app_2_d$mask_fine_dollars[2],hu_app_2_d$mask_fine_dollars[3],hu_app_2_d$sd[2],hu_app_2_d$sd[3],hu_app_2_d$N[2],hu_app_2_d$N[3])
t.test2(hu_app_2_d$mask_fine_dollars[2],hu_app_2_d$mask_fine_dollars[4],hu_app_2_d$sd[2],hu_app_2_d$sd[4],hu_app_2_d$N[2],hu_app_2_d$N[4])
t.test2(hu_app_2_d$mask_fine_dollars[3],hu_app_2_d$mask_fine_dollars[4],hu_app_2_d$sd[3],hu_app_2_d$sd[4],hu_app_2_d$N[3],hu_app_2_d$N[4])

pl_app_2_d<-summarySE(pl_dat_plot, measurevar="mask_fine_dollars", groupvars=c("type"))
t.test2(pl_app_2_d$mask_fine_dollars[1],pl_app_2_d$mask_fine_dollars[2],pl_app_2_d$sd[1],pl_app_2_d$sd[2],pl_app_2_d$N[1],pl_app_2_d$N[2])
t.test2(pl_app_2_d$mask_fine_dollars[1],pl_app_2_d$mask_fine_dollars[3],pl_app_2_d$sd[1],pl_app_2_d$sd[3],pl_app_2_d$N[1],pl_app_2_d$N[3])
t.test2(pl_app_2_d$mask_fine_dollars[1],pl_app_2_d$mask_fine_dollars[4],pl_app_2_d$sd[1],pl_app_2_d$sd[4],pl_app_2_d$N[1],pl_app_2_d$N[4])
t.test2(pl_app_2_d$mask_fine_dollars[2],pl_app_2_d$mask_fine_dollars[3],pl_app_2_d$sd[2],pl_app_2_d$sd[3],pl_app_2_d$N[2],pl_app_2_d$N[3])
t.test2(pl_app_2_d$mask_fine_dollars[2],pl_app_2_d$mask_fine_dollars[4],pl_app_2_d$sd[2],pl_app_2_d$sd[4],pl_app_2_d$N[2],pl_app_2_d$N[4])
t.test2(pl_app_2_d$mask_fine_dollars[3],pl_app_2_d$mask_fine_dollars[4],pl_app_2_d$sd[3],pl_app_2_d$sd[4],pl_app_2_d$N[3],pl_app_2_d$N[4])

####Table B2: Figure B3 Germany T-test results (dollar adjusted)

ge_app_3_d <- summarySE(ge_dat_plot, measurevar="fine_amount_w2_dollars", groupvars=c("treat_1_w2","covid_concern"))
ge_app_3_d <-na.omit(ge_app_3_d)
t.test2(ge_app_3_d$fine_amount_w2[1],ge_app_3_d$fine_amount_w2[2],ge_app_3_d$sd[1],ge_app_3_d$sd[2],ge_app_3_d$N[1],ge_app_3_d$N[2])
t.test2(ge_app_3_d$fine_amount_w2[1],ge_app_3_d$fine_amount_w2[3],ge_app_3_d$sd[1],ge_app_3_d$sd[3],ge_app_3_d$N[1],ge_app_3_d$N[3])
t.test2(ge_app_3_d$fine_amount_w2[1],ge_app_3_d$fine_amount_w2[4],ge_app_3_d$sd[1],ge_app_3_d$sd[4],ge_app_3_d$N[1],ge_app_3_d$N[4])
t.test2(ge_app_3_d$fine_amount_w2[1],ge_app_3_d$fine_amount_w2[5],ge_app_3_d$sd[1],ge_app_3_d$sd[5],ge_app_3_d$N[1],ge_app_3_d$N[5])
t.test2(ge_app_3_d$fine_amount_w2[1],ge_app_3_d$fine_amount_w2[6],ge_app_3_d$sd[1],ge_app_3_d$sd[6],ge_app_3_d$N[1],ge_app_3_d$N[6])
t.test2(ge_app_3_d$fine_amount_w2[1],ge_app_3_d$fine_amount_w2[7],ge_app_3_d$sd[1],ge_app_3_d$sd[7],ge_app_3_d$N[1],ge_app_3_d$N[7])
t.test2(ge_app_3_d$fine_amount_w2[1],ge_app_3_d$fine_amount_w2[8],ge_app_3_d$sd[1],ge_app_3_d$sd[8],ge_app_3_d$N[1],ge_app_3_d$N[8])
t.test2(ge_app_3_d$fine_amount_w2[2],ge_app_3_d$fine_amount_w2[3],ge_app_3_d$sd[2],ge_app_3_d$sd[3],ge_app_3_d$N[2],ge_app_3_d$N[3])
t.test2(ge_app_3_d$fine_amount_w2[2],ge_app_3_d$fine_amount_w2[4],ge_app_3_d$sd[2],ge_app_3_d$sd[4],ge_app_3_d$N[2],ge_app_3_d$N[4])
t.test2(ge_app_3_d$fine_amount_w2[2],ge_app_3_d$fine_amount_w2[5],ge_app_3_d$sd[2],ge_app_3_d$sd[5],ge_app_3_d$N[2],ge_app_3_d$N[5])
t.test2(ge_app_3_d$fine_amount_w2[2],ge_app_3_d$fine_amount_w2[6],ge_app_3_d$sd[2],ge_app_3_d$sd[6],ge_app_3_d$N[2],ge_app_3_d$N[6])
t.test2(ge_app_3_d$fine_amount_w2[2],ge_app_3_d$fine_amount_w2[7],ge_app_3_d$sd[2],ge_app_3_d$sd[7],ge_app_3_d$N[2],ge_app_3_d$N[7])
t.test2(ge_app_3_d$fine_amount_w2[2],ge_app_3_d$fine_amount_w2[8],ge_app_3_d$sd[2],ge_app_3_d$sd[8],ge_app_3_d$N[2],ge_app_3_d$N[8])
t.test2(ge_app_3_d$fine_amount_w2[3],ge_app_3_d$fine_amount_w2[4],ge_app_3_d$sd[3],ge_app_3_d$sd[4],ge_app_3_d$N[3],ge_app_3_d$N[4])
t.test2(ge_app_3_d$fine_amount_w2[3],ge_app_3_d$fine_amount_w2[5],ge_app_3_d$sd[3],ge_app_3_d$sd[5],ge_app_3_d$N[3],ge_app_3_d$N[5])
t.test2(ge_app_3_d$fine_amount_w2[3],ge_app_3_d$fine_amount_w2[6],ge_app_3_d$sd[3],ge_app_3_d$sd[6],ge_app_3_d$N[3],ge_app_3_d$N[6])
t.test2(ge_app_3_d$fine_amount_w2[3],ge_app_3_d$fine_amount_w2[7],ge_app_3_d$sd[3],ge_app_3_d$sd[7],ge_app_3_d$N[3],ge_app_3_d$N[7])
t.test2(ge_app_3_d$fine_amount_w2[3],ge_app_3_d$fine_amount_w2[8],ge_app_3_d$sd[3],ge_app_3_d$sd[8],ge_app_3_d$N[3],ge_app_3_d$N[8])
t.test2(ge_app_3_d$fine_amount_w2[4],ge_app_3_d$fine_amount_w2[5],ge_app_3_d$sd[4],ge_app_3_d$sd[5],ge_app_3_d$N[4],ge_app_3_d$N[5])
t.test2(ge_app_3_d$fine_amount_w2[4],ge_app_3_d$fine_amount_w2[6],ge_app_3_d$sd[4],ge_app_3_d$sd[6],ge_app_3_d$N[4],ge_app_3_d$N[6])
t.test2(ge_app_3_d$fine_amount_w2[4],ge_app_3_d$fine_amount_w2[7],ge_app_3_d$sd[4],ge_app_3_d$sd[7],ge_app_3_d$N[4],ge_app_3_d$N[7])
t.test2(ge_app_3_d$fine_amount_w2[4],ge_app_3_d$fine_amount_w2[8],ge_app_3_d$sd[4],ge_app_3_d$sd[8],ge_app_3_d$N[4],ge_app_3_d$N[8])
t.test2(ge_app_3_d$fine_amount_w2[5],ge_app_3_d$fine_amount_w2[6],ge_app_3_d$sd[5],ge_app_3_d$sd[6],ge_app_3_d$N[5],ge_app_3_d$N[6])
t.test2(ge_app_3_d$fine_amount_w2[5],ge_app_3_d$fine_amount_w2[7],ge_app_3_d$sd[5],ge_app_3_d$sd[7],ge_app_3_d$N[5],ge_app_3_d$N[7])
t.test2(ge_app_3_d$fine_amount_w2[5],ge_app_3_d$fine_amount_w2[8],ge_app_3_d$sd[5],ge_app_3_d$sd[8],ge_app_3_d$N[5],ge_app_3_d$N[8])
t.test2(ge_app_3_d$fine_amount_w2[6],ge_app_3_d$fine_amount_w2[7],ge_app_3_d$sd[6],ge_app_3_d$sd[7],ge_app_3_d$N[6],ge_app_3_d$N[7])
t.test2(ge_app_3_d$fine_amount_w2[6],ge_app_3_d$fine_amount_w2[8],ge_app_3_d$sd[6],ge_app_3_d$sd[8],ge_app_3_d$N[6],ge_app_3_d$N[8])
t.test2(ge_app_3_d$fine_amount_w2[7],ge_app_3_d$fine_amount_w2[8],ge_app_3_d$sd[7],ge_app_3_d$sd[8],ge_app_3_d$N[7],ge_app_3_d$N[8])

####Table B3: Figure B3 US T-test results (dollar adjusted)

us_app_3 <- summarySE(us_dat_plot, measurevar="mask_fine", groupvars=c("type","covid_concern"))
us_app_3 <-na.omit(us_app_3)
t.test2(us_app_3$mask_fine[1],us_app_3$mask_fine[2],us_app_3$sd[1],us_app_3$sd[2],us_app_3$N[1],us_app_3$N[2])
t.test2(us_app_3$mask_fine[1],us_app_3$mask_fine[3],us_app_3$sd[1],us_app_3$sd[3],us_app_3$N[1],us_app_3$N[3])
t.test2(us_app_3$mask_fine[1],us_app_3$mask_fine[4],us_app_3$sd[1],us_app_3$sd[4],us_app_3$N[1],us_app_3$N[4])
t.test2(us_app_3$mask_fine[1],us_app_3$mask_fine[5],us_app_3$sd[1],us_app_3$sd[5],us_app_3$N[1],us_app_3$N[5])
t.test2(us_app_3$mask_fine[1],us_app_3$mask_fine[6],us_app_3$sd[1],us_app_3$sd[6],us_app_3$N[1],us_app_3$N[6])
t.test2(us_app_3$mask_fine[1],us_app_3$mask_fine[7],us_app_3$sd[1],us_app_3$sd[7],us_app_3$N[1],us_app_3$N[7])
t.test2(us_app_3$mask_fine[1],us_app_3$mask_fine[8],us_app_3$sd[1],us_app_3$sd[8],us_app_3$N[1],us_app_3$N[8])
t.test2(us_app_3$mask_fine[2],us_app_3$mask_fine[3],us_app_3$sd[2],us_app_3$sd[3],us_app_3$N[2],us_app_3$N[3])
t.test2(us_app_3$mask_fine[2],us_app_3$mask_fine[4],us_app_3$sd[2],us_app_3$sd[4],us_app_3$N[2],us_app_3$N[4])
t.test2(us_app_3$mask_fine[2],us_app_3$mask_fine[5],us_app_3$sd[2],us_app_3$sd[5],us_app_3$N[2],us_app_3$N[5])
t.test2(us_app_3$mask_fine[2],us_app_3$mask_fine[6],us_app_3$sd[2],us_app_3$sd[6],us_app_3$N[2],us_app_3$N[6])
t.test2(us_app_3$mask_fine[2],us_app_3$mask_fine[7],us_app_3$sd[2],us_app_3$sd[7],us_app_3$N[2],us_app_3$N[7])
t.test2(us_app_3$mask_fine[2],us_app_3$mask_fine[8],us_app_3$sd[2],us_app_3$sd[8],us_app_3$N[2],us_app_3$N[8])
t.test2(us_app_3$mask_fine[3],us_app_3$mask_fine[4],us_app_3$sd[3],us_app_3$sd[4],us_app_3$N[3],us_app_3$N[4])
t.test2(us_app_3$mask_fine[3],us_app_3$mask_fine[5],us_app_3$sd[3],us_app_3$sd[5],us_app_3$N[3],us_app_3$N[5])
t.test2(us_app_3$mask_fine[3],us_app_3$mask_fine[6],us_app_3$sd[3],us_app_3$sd[6],us_app_3$N[3],us_app_3$N[6])
t.test2(us_app_3$mask_fine[3],us_app_3$mask_fine[7],us_app_3$sd[3],us_app_3$sd[7],us_app_3$N[3],us_app_3$N[7])
t.test2(us_app_3$mask_fine[3],us_app_3$mask_fine[8],us_app_3$sd[3],us_app_3$sd[8],us_app_3$N[3],us_app_3$N[8])
t.test2(us_app_3$mask_fine[4],us_app_3$mask_fine[5],us_app_3$sd[4],us_app_3$sd[5],us_app_3$N[4],us_app_3$N[5])
t.test2(us_app_3$mask_fine[4],us_app_3$mask_fine[6],us_app_3$sd[4],us_app_3$sd[6],us_app_3$N[4],us_app_3$N[6])
t.test2(us_app_3$mask_fine[4],us_app_3$mask_fine[7],us_app_3$sd[4],us_app_3$sd[7],us_app_3$N[4],us_app_3$N[7])
t.test2(us_app_3$mask_fine[4],us_app_3$mask_fine[8],us_app_3$sd[4],us_app_3$sd[8],us_app_3$N[4],us_app_3$N[8])
t.test2(us_app_3$mask_fine[5],us_app_3$mask_fine[6],us_app_3$sd[5],us_app_3$sd[6],us_app_3$N[5],us_app_3$N[6])
t.test2(us_app_3$mask_fine[5],us_app_3$mask_fine[7],us_app_3$sd[5],us_app_3$sd[7],us_app_3$N[5],us_app_3$N[7])
t.test2(us_app_3$mask_fine[5],us_app_3$mask_fine[8],us_app_3$sd[5],us_app_3$sd[8],us_app_3$N[5],us_app_3$N[8])
t.test2(us_app_3$mask_fine[6],us_app_3$mask_fine[7],us_app_3$sd[6],us_app_3$sd[7],us_app_3$N[6],us_app_3$N[7])
t.test2(us_app_3$mask_fine[6],us_app_3$mask_fine[8],us_app_3$sd[6],us_app_3$sd[8],us_app_3$N[6],us_app_3$N[8])
t.test2(us_app_3$mask_fine[7],us_app_3$mask_fine[8],us_app_3$sd[7],us_app_3$sd[8],us_app_3$N[7],us_app_3$N[8])

####Table B4: Figure B3 Hungary T-test results (dollar adjusted)

hu_app_3_d <- summarySE(hu_dat_plot, measurevar="mask_fine_dollars", groupvars=c("type","covid_concern"))
hu_app_3_d <-na.omit(hu_app_3_d)
t.test2(hu_app_3_d$mask_fine_dollars[1],hu_app_3_d$mask_fine_dollars[2],hu_app_3_d$sd[1],hu_app_3_d$sd[2],hu_app_3_d$N[1],hu_app_3_d$N[2])
t.test2(hu_app_3_d$mask_fine_dollars[1],hu_app_3_d$mask_fine_dollars[3],hu_app_3_d$sd[1],hu_app_3_d$sd[3],hu_app_3_d$N[1],hu_app_3_d$N[3])
t.test2(hu_app_3_d$mask_fine_dollars[1],hu_app_3_d$mask_fine_dollars[4],hu_app_3_d$sd[1],hu_app_3_d$sd[4],hu_app_3_d$N[1],hu_app_3_d$N[4])
t.test2(hu_app_3_d$mask_fine_dollars[1],hu_app_3_d$mask_fine_dollars[5],hu_app_3_d$sd[1],hu_app_3_d$sd[5],hu_app_3_d$N[1],hu_app_3_d$N[5])
t.test2(hu_app_3_d$mask_fine_dollars[1],hu_app_3_d$mask_fine_dollars[6],hu_app_3_d$sd[1],hu_app_3_d$sd[6],hu_app_3_d$N[1],hu_app_3_d$N[6])
t.test2(hu_app_3_d$mask_fine_dollars[1],hu_app_3_d$mask_fine_dollars[7],hu_app_3_d$sd[1],hu_app_3_d$sd[7],hu_app_3_d$N[1],hu_app_3_d$N[7])
t.test2(hu_app_3_d$mask_fine_dollars[1],hu_app_3_d$mask_fine_dollars[8],hu_app_3_d$sd[1],hu_app_3_d$sd[8],hu_app_3_d$N[1],hu_app_3_d$N[8])
t.test2(hu_app_3_d$mask_fine_dollars[2],hu_app_3_d$mask_fine_dollars[3],hu_app_3_d$sd[2],hu_app_3_d$sd[3],hu_app_3_d$N[2],hu_app_3_d$N[3])
t.test2(hu_app_3_d$mask_fine_dollars[2],hu_app_3_d$mask_fine_dollars[4],hu_app_3_d$sd[2],hu_app_3_d$sd[4],hu_app_3_d$N[2],hu_app_3_d$N[4])
t.test2(hu_app_3_d$mask_fine_dollars[2],hu_app_3_d$mask_fine_dollars[5],hu_app_3_d$sd[2],hu_app_3_d$sd[5],hu_app_3_d$N[2],hu_app_3_d$N[5])
t.test2(hu_app_3_d$mask_fine_dollars[2],hu_app_3_d$mask_fine_dollars[6],hu_app_3_d$sd[2],hu_app_3_d$sd[6],hu_app_3_d$N[2],hu_app_3_d$N[6])
t.test2(hu_app_3_d$mask_fine_dollars[2],hu_app_3_d$mask_fine_dollars[7],hu_app_3_d$sd[2],hu_app_3_d$sd[7],hu_app_3_d$N[2],hu_app_3_d$N[7])
t.test2(hu_app_3_d$mask_fine_dollars[2],hu_app_3_d$mask_fine_dollars[8],hu_app_3_d$sd[2],hu_app_3_d$sd[8],hu_app_3_d$N[2],hu_app_3_d$N[8])
t.test2(hu_app_3_d$mask_fine_dollars[3],hu_app_3_d$mask_fine_dollars[4],hu_app_3_d$sd[3],hu_app_3_d$sd[4],hu_app_3_d$N[3],hu_app_3_d$N[4])
t.test2(hu_app_3_d$mask_fine_dollars[3],hu_app_3_d$mask_fine_dollars[5],hu_app_3_d$sd[3],hu_app_3_d$sd[5],hu_app_3_d$N[3],hu_app_3_d$N[5])
t.test2(hu_app_3_d$mask_fine_dollars[3],hu_app_3_d$mask_fine_dollars[6],hu_app_3_d$sd[3],hu_app_3_d$sd[6],hu_app_3_d$N[3],hu_app_3_d$N[6])
t.test2(hu_app_3_d$mask_fine_dollars[3],hu_app_3_d$mask_fine_dollars[7],hu_app_3_d$sd[3],hu_app_3_d$sd[7],hu_app_3_d$N[3],hu_app_3_d$N[7])
t.test2(hu_app_3_d$mask_fine_dollars[3],hu_app_3_d$mask_fine_dollars[8],hu_app_3_d$sd[3],hu_app_3_d$sd[8],hu_app_3_d$N[3],hu_app_3_d$N[8])
t.test2(hu_app_3_d$mask_fine_dollars[4],hu_app_3_d$mask_fine_dollars[5],hu_app_3_d$sd[4],hu_app_3_d$sd[5],hu_app_3_d$N[4],hu_app_3_d$N[5])
t.test2(hu_app_3_d$mask_fine_dollars[4],hu_app_3_d$mask_fine_dollars[6],hu_app_3_d$sd[4],hu_app_3_d$sd[6],hu_app_3_d$N[4],hu_app_3_d$N[6])
t.test2(hu_app_3_d$mask_fine_dollars[4],hu_app_3_d$mask_fine_dollars[7],hu_app_3_d$sd[4],hu_app_3_d$sd[7],hu_app_3_d$N[4],hu_app_3_d$N[7])
t.test2(hu_app_3_d$mask_fine_dollars[4],hu_app_3_d$mask_fine_dollars[8],hu_app_3_d$sd[4],hu_app_3_d$sd[8],hu_app_3_d$N[4],hu_app_3_d$N[8])
t.test2(hu_app_3_d$mask_fine_dollars[5],hu_app_3_d$mask_fine_dollars[6],hu_app_3_d$sd[5],hu_app_3_d$sd[6],hu_app_3_d$N[5],hu_app_3_d$N[6])
t.test2(hu_app_3_d$mask_fine_dollars[5],hu_app_3_d$mask_fine_dollars[7],hu_app_3_d$sd[5],hu_app_3_d$sd[7],hu_app_3_d$N[5],hu_app_3_d$N[7])
t.test2(hu_app_3_d$mask_fine_dollars[5],hu_app_3_d$mask_fine_dollars[8],hu_app_3_d$sd[5],hu_app_3_d$sd[8],hu_app_3_d$N[5],hu_app_3_d$N[8])
t.test2(hu_app_3_d$mask_fine_dollars[6],hu_app_3_d$mask_fine_dollars[7],hu_app_3_d$sd[6],hu_app_3_d$sd[7],hu_app_3_d$N[6],hu_app_3_d$N[7])
t.test2(hu_app_3_d$mask_fine_dollars[6],hu_app_3_d$mask_fine_dollars[8],hu_app_3_d$sd[6],hu_app_3_d$sd[8],hu_app_3_d$N[6],hu_app_3_d$N[8])
t.test2(hu_app_3_d$mask_fine_dollars[7],hu_app_3_d$mask_fine_dollars[8],hu_app_3_d$sd[7],hu_app_3_d$sd[8],hu_app_3_d$N[7],hu_app_3_d$N[8])

####Table B5: Figure B3 Poland T-test results (dollar adjusted)

pl_app_3_d <- summarySE(pl_dat_plot, measurevar="mask_fine_dollars", groupvars=c("type","covid_concern"))
pl_app_3_d <-na.omit(pl_app_3_d)
t.test2(pl_app_3_d$mask_fine_dollars[1],pl_app_3_d$mask_fine_dollars[2],pl_app_3_d$sd[1],pl_app_3_d$sd[2],pl_app_3_d$N[1],pl_app_3_d$N[2])
t.test2(pl_app_3_d$mask_fine_dollars[1],pl_app_3_d$mask_fine_dollars[3],pl_app_3_d$sd[1],pl_app_3_d$sd[3],pl_app_3_d$N[1],pl_app_3_d$N[3])
t.test2(pl_app_3_d$mask_fine_dollars[1],pl_app_3_d$mask_fine_dollars[4],pl_app_3_d$sd[1],pl_app_3_d$sd[4],pl_app_3_d$N[1],pl_app_3_d$N[4])
t.test2(pl_app_3_d$mask_fine_dollars[1],pl_app_3_d$mask_fine_dollars[5],pl_app_3_d$sd[1],pl_app_3_d$sd[5],pl_app_3_d$N[1],pl_app_3_d$N[5])
t.test2(pl_app_3_d$mask_fine_dollars[1],pl_app_3_d$mask_fine_dollars[6],pl_app_3_d$sd[1],pl_app_3_d$sd[6],pl_app_3_d$N[1],pl_app_3_d$N[6])
t.test2(pl_app_3_d$mask_fine_dollars[1],pl_app_3_d$mask_fine_dollars[7],pl_app_3_d$sd[1],pl_app_3_d$sd[7],pl_app_3_d$N[1],pl_app_3_d$N[7])
t.test2(pl_app_3_d$mask_fine_dollars[1],pl_app_3_d$mask_fine_dollars[8],pl_app_3_d$sd[1],pl_app_3_d$sd[8],pl_app_3_d$N[1],pl_app_3_d$N[8])
t.test2(pl_app_3_d$mask_fine_dollars[2],pl_app_3_d$mask_fine_dollars[3],pl_app_3_d$sd[2],pl_app_3_d$sd[3],pl_app_3_d$N[2],pl_app_3_d$N[3])
t.test2(pl_app_3_d$mask_fine_dollars[2],pl_app_3_d$mask_fine_dollars[4],pl_app_3_d$sd[2],pl_app_3_d$sd[4],pl_app_3_d$N[2],pl_app_3_d$N[4])
t.test2(pl_app_3_d$mask_fine_dollars[2],pl_app_3_d$mask_fine_dollars[5],pl_app_3_d$sd[2],pl_app_3_d$sd[5],pl_app_3_d$N[2],pl_app_3_d$N[5])
t.test2(pl_app_3_d$mask_fine_dollars[2],pl_app_3_d$mask_fine_dollars[6],pl_app_3_d$sd[2],pl_app_3_d$sd[6],pl_app_3_d$N[2],pl_app_3_d$N[6])
t.test2(pl_app_3_d$mask_fine_dollars[2],pl_app_3_d$mask_fine_dollars[7],pl_app_3_d$sd[2],pl_app_3_d$sd[7],pl_app_3_d$N[2],pl_app_3_d$N[7])
t.test2(pl_app_3_d$mask_fine_dollars[2],pl_app_3_d$mask_fine_dollars[8],pl_app_3_d$sd[2],pl_app_3_d$sd[8],pl_app_3_d$N[2],pl_app_3_d$N[8])
t.test2(pl_app_3_d$mask_fine_dollars[3],pl_app_3_d$mask_fine_dollars[4],pl_app_3_d$sd[3],pl_app_3_d$sd[4],pl_app_3_d$N[3],pl_app_3_d$N[4])
t.test2(pl_app_3_d$mask_fine_dollars[3],pl_app_3_d$mask_fine_dollars[5],pl_app_3_d$sd[3],pl_app_3_d$sd[5],pl_app_3_d$N[3],pl_app_3_d$N[5])
t.test2(pl_app_3_d$mask_fine_dollars[3],pl_app_3_d$mask_fine_dollars[6],pl_app_3_d$sd[3],pl_app_3_d$sd[6],pl_app_3_d$N[3],pl_app_3_d$N[6])
t.test2(pl_app_3_d$mask_fine_dollars[3],pl_app_3_d$mask_fine_dollars[7],pl_app_3_d$sd[3],pl_app_3_d$sd[7],pl_app_3_d$N[3],pl_app_3_d$N[7])
t.test2(pl_app_3_d$mask_fine_dollars[3],pl_app_3_d$mask_fine_dollars[8],pl_app_3_d$sd[3],pl_app_3_d$sd[8],pl_app_3_d$N[3],pl_app_3_d$N[8])
t.test2(pl_app_3_d$mask_fine_dollars[4],pl_app_3_d$mask_fine_dollars[5],pl_app_3_d$sd[4],pl_app_3_d$sd[5],pl_app_3_d$N[4],pl_app_3_d$N[5])
t.test2(pl_app_3_d$mask_fine_dollars[4],pl_app_3_d$mask_fine_dollars[6],pl_app_3_d$sd[4],pl_app_3_d$sd[6],pl_app_3_d$N[4],pl_app_3_d$N[6])
t.test2(pl_app_3_d$mask_fine_dollars[4],pl_app_3_d$mask_fine_dollars[7],pl_app_3_d$sd[4],pl_app_3_d$sd[7],pl_app_3_d$N[4],pl_app_3_d$N[7])
t.test2(pl_app_3_d$mask_fine_dollars[4],pl_app_3_d$mask_fine_dollars[8],pl_app_3_d$sd[4],pl_app_3_d$sd[8],pl_app_3_d$N[4],pl_app_3_d$N[8])
t.test2(pl_app_3_d$mask_fine_dollars[5],pl_app_3_d$mask_fine_dollars[6],pl_app_3_d$sd[5],pl_app_3_d$sd[6],pl_app_3_d$N[5],pl_app_3_d$N[6])
t.test2(pl_app_3_d$mask_fine_dollars[5],pl_app_3_d$mask_fine_dollars[7],pl_app_3_d$sd[5],pl_app_3_d$sd[7],pl_app_3_d$N[5],pl_app_3_d$N[7])
t.test2(pl_app_3_d$mask_fine_dollars[5],pl_app_3_d$mask_fine_dollars[8],pl_app_3_d$sd[5],pl_app_3_d$sd[8],pl_app_3_d$N[5],pl_app_3_d$N[8])
t.test2(pl_app_3_d$mask_fine_dollars[6],pl_app_3_d$mask_fine_dollars[7],pl_app_3_d$sd[6],pl_app_3_d$sd[7],pl_app_3_d$N[6],pl_app_3_d$N[7])
t.test2(pl_app_3_d$mask_fine_dollars[6],pl_app_3_d$mask_fine_dollars[8],pl_app_3_d$sd[6],pl_app_3_d$sd[8],pl_app_3_d$N[6],pl_app_3_d$N[8])
t.test2(pl_app_3_d$mask_fine_dollars[7],pl_app_3_d$mask_fine_dollars[8],pl_app_3_d$sd[7],pl_app_3_d$sd[8],pl_app_3_d$N[7],pl_app_3_d$N[8])

####Table B6,7: Regressions

###setting up variables before running the models

#defining education variables for each country
#Germany
ge_dat_plot$education<-NA
ge_dat_plot$education[which(ge_dat_plot$education_pdl_new==2)]<-1
ge_dat_plot$education[which(ge_dat_plot$education_pdl_new==3)]<-0.33
ge_dat_plot$education[which(ge_dat_plot$education_pdl_new==4)]<-0.66
ge_dat_plot$education[which(ge_dat_plot$education_pdl_new==5)]<-0.66
ge_dat_plot$education[which(ge_dat_plot$education_pdl_new==6)]<-0
ge_dat_plot$education[which(ge_dat_plot$education_pdl_new==7)]<-0
ge_dat_plot$education[which(ge_dat_plot$education_pdl_new==8)]<-NA

#US
us_dat_plot$education<-NA
us_dat_plot$education[which(us_dat_plot$educ==1)]<-0
us_dat_plot$education[which(us_dat_plot$educ==2)]<-0.33
us_dat_plot$education[which(us_dat_plot$educ==3)]<-0.66
us_dat_plot$education[which(us_dat_plot$educ==4)]<-0.66
us_dat_plot$education[which(us_dat_plot$educ==5)]<-1
us_dat_plot$education[which(us_dat_plot$educ==6)]<-1
us_dat_plot$education[which(us_dat_plot$educ==8)]<-NA
us_dat_plot$education[which(us_dat_plot$educ==9)]<-NA

#Hungary
hu_dat_plot$education<-NA
hu_dat_plot$education[which(hu_dat_plot$education_age_EU_local==1)]<-0
hu_dat_plot$education[which(hu_dat_plot$education_age_EU_local==2)]<-0
hu_dat_plot$education[which(hu_dat_plot$education_age_EU_local==3)]<-0.33
hu_dat_plot$education[which(hu_dat_plot$education_age_EU_local==4)]<-0.33
hu_dat_plot$education[which(hu_dat_plot$education_age_EU_local==5)]<-0.66
hu_dat_plot$education[which(hu_dat_plot$education_age_EU_local==6)]<-0.66
hu_dat_plot$education[which(hu_dat_plot$education_age_EU_local==7)]<-1

#Poland
pl_dat_plot$education<-NA
pl_dat_plot$education[which(pl_dat_plot$education_age_EU_local==1)]<-0
pl_dat_plot$education[which(pl_dat_plot$education_age_EU_local==2)]<-0
pl_dat_plot$education[which(pl_dat_plot$education_age_EU_local==3)]<-0.33
pl_dat_plot$education[which(pl_dat_plot$education_age_EU_local==4)]<-0.33
pl_dat_plot$education[which(pl_dat_plot$education_age_EU_local==5)]<-0.66
pl_dat_plot$education[which(pl_dat_plot$education_age_EU_local==6)]<-0.66
pl_dat_plot$education[which(pl_dat_plot$education_age_EU_local==7)]<-1

#recoding vaccine status variables for each country (except for Germany)
#US
us_dat_plot$vaccine<-NA
us_dat_plot$vaccine[which(us_dat_plot$vaccine_status==1)]<-1
us_dat_plot$vaccine[which(us_dat_plot$vaccine_status==2)]<-1
us_dat_plot$vaccine[which(us_dat_plot$vaccine_status==3)]<-0.66
us_dat_plot$vaccine[which(us_dat_plot$vaccine_status==4)]<-0
us_dat_plot$vaccine[which(us_dat_plot$vaccine_status==5)]<-0.33

#Hungary
hu_dat_plot$vaccine<-NA
hu_dat_plot$vaccine[which(hu_dat_plot$vaccine_status==1)]<-1
hu_dat_plot$vaccine[which(hu_dat_plot$vaccine_status==2)]<-1
hu_dat_plot$vaccine[which(hu_dat_plot$vaccine_status==3)]<-0.66
hu_dat_plot$vaccine[which(hu_dat_plot$vaccine_status==4)]<-0
hu_dat_plot$vaccine[which(hu_dat_plot$vaccine_status==5)]<-0.33

#Poland
pl_dat_plot$vaccine<-NA
pl_dat_plot$vaccine[which(pl_dat_plot$vaccine_status==1)]<-1
pl_dat_plot$vaccine[which(pl_dat_plot$vaccine_status==2)]<-1
pl_dat_plot$vaccine[which(pl_dat_plot$vaccine_status==3)]<-0.66
pl_dat_plot$vaccine[which(pl_dat_plot$vaccine_status==4)]<-0
pl_dat_plot$vaccine[which(pl_dat_plot$vaccine_status==5)]<-0.33

#rescale ideology
ge_dat_plot$ideology<-ge_dat_plot$l_r_place/10
us_dat_plot$ideology<-us_dat_plot$ideo5/5
hu_dat_plot$ideology<-hu_dat_plot$ideo10/10
pl_dat_plot$ideology<-pl_dat_plot$ideo10/10
#us race
us_dat_plot$white<-NA
us_dat_plot$white[which(us_dat_plot$race==1)]<-1
us_dat_plot$white[which(!us_dat_plot$race==1)]<-0

#releveling factors
ge_dat_plot$type2= relevel(ge_dat_plot$treat_1_w2, ref=4)
us_dat_plot$type2= relevel(us_dat_plot$type, ref=4)
hu_dat_plot$type2= relevel(hu_dat_plot$type, ref=4)
pl_dat_plot$type2= relevel(pl_dat_plot$type, ref=4)

#rescale rural
ge_dat_plot$rural<-NA
ge_dat_plot$rural[which(ge_dat_plot$urban==3)]<-1
ge_dat_plot$rural[which(!ge_dat_plot$urban==3)]<-0
us_dat_plot$rural<-NA
us_dat_plot$rural[which(us_dat_plot$urbancity==4)]<-1
us_dat_plot$rural[which(!us_dat_plot$urbancity==4)]<-0
hu_dat_plot$rural<-NA
hu_dat_plot$rural[which(hu_dat_plot$urban_rural==4)]<-1
hu_dat_plot$rural[which(!hu_dat_plot$urban_rural==4)]<-0
pl_dat_plot$rural<-NA
pl_dat_plot$rural[which(pl_dat_plot$urban_rural==4)]<-1
pl_dat_plot$rural[which(!pl_dat_plot$urban_rural==4)]<-0

#rescale political interest
ge_dat_plot$political_interest<-(5-ge_dat_plot$political_interest)/4
unique(us_dat_plot$newsint)
us_dat_plot$newsint[which(us_dat_plot$newsint==7)]<-NA
us_dat_plot$political_interest<-(5-us_dat_plot$newsint)/4
hu_dat_plot$political_interest<-(6-hu_dat_plot$political_interest)/5
pl_dat_plot$political_interest<-(6-pl_dat_plot$political_interest)/5

#rescale gender
ge_dat_plot$gender<-ge_dat_plot$gender-1 #1 female
us_dat_plot$gender<-us_dat_plot$gender-1
hu_dat_plot$gender<-hu_dat_plot$gender-1
pl_dat_plot$gender<-pl_dat_plot$gender-1
#rescale agegroup
ge_dat_plot$ageGroup<-ge_dat_plot$ageGroup/4 #bigger older
us_dat_plot$ageGroup<-us_dat_plot$ageGroup/4
hu_dat_plot$ageGroup<-hu_dat_plot$ageGroup/4
pl_dat_plot$ageGroup<-pl_dat_plot$ageGroup/4

#rescale and create fined
#Germany
ge_dat_plot$fined<-NA
ge_dat_plot$fined[which(ge_dat_plot$treat_1_2_w2==1)]<-1
ge_dat_plot$fined[which(ge_dat_plot$treat_1_2_w2==2)]<-0
#Poland
pl_dat_plot$fined<-NA
pl_dat_plot$fined[which(pl_dat_plot$mask_2_treatment==1)]<-1
pl_dat_plot$fined[which(pl_dat_plot$mask_2_treatment==2)]<-0
#Hungary
hu_dat_plot$fined<-NA
hu_dat_plot$fined[which(hu_dat_plot$mask_2_treatment==1)]<-1
hu_dat_plot$fined[which(hu_dat_plot$mask_2_treatment==2)]<-0
#US
us_dat_plot$fined<-NA
us_dat_plot$fined[which(us_dat_plot$mask_2_treatment==1)]<-1
us_dat_plot$fined[which(us_dat_plot$mask_2_treatment==2)]<-0

#Germany extra dv recode
ge_dat_plot$mask_usage_final<-NA
ge_dat_plot$mask_usage_final[which(ge_dat_plot$mask_usage_post_w2==1)]<-5
ge_dat_plot$mask_usage_final[which(ge_dat_plot$mask_usage_post_w2==2)]<-4
ge_dat_plot$mask_usage_final[which(ge_dat_plot$mask_usage_post_w2==3)]<-3
ge_dat_plot$mask_usage_final[which(ge_dat_plot$mask_usage_post_w2==4)]<-2
ge_dat_plot$mask_usage_final[which(ge_dat_plot$mask_usage_post_w2==5)]<-1

#rescale and create mask_man
#Germany
ge_dat_plot$mask_man<-NA
ge_dat_plot$mask_man[which(ge_dat_plot$mask_support_w2==1)]<-1
ge_dat_plot$mask_man[which(ge_dat_plot$mask_support_w2==2)]<-0.66
ge_dat_plot$mask_man[which(ge_dat_plot$mask_support_w2==3)]<-0.33
ge_dat_plot$mask_man[which(ge_dat_plot$mask_support_w2==4)]<-0

#poland
pl_dat_plot$mask_man<-NA
pl_dat_plot$mask_man[which(pl_dat_plot$mask_support==1)]<-1
pl_dat_plot$mask_man[which(pl_dat_plot$mask_support==2)]<-0.66
pl_dat_plot$mask_man[which(pl_dat_plot$mask_support==3)]<-0.33
pl_dat_plot$mask_man[which(pl_dat_plot$mask_support==4)]<-0

#hungary
hu_dat_plot$mask_man<-NA
hu_dat_plot$mask_man[which(hu_dat_plot$mask_support==1)]<-1
hu_dat_plot$mask_man[which(hu_dat_plot$mask_support==2)]<-0.66
hu_dat_plot$mask_man[which(hu_dat_plot$mask_support==3)]<-0.33
hu_dat_plot$mask_man[which(hu_dat_plot$mask_support==4)]<-0

#US
us_dat_plot$mask_man<-NA
us_dat_plot$mask_man[which(us_dat_plot$mask_support==1)]<-1
us_dat_plot$mask_man[which(us_dat_plot$mask_support==2)]<-0.66
us_dat_plot$mask_man[which(us_dat_plot$mask_support==3)]<-0.33
us_dat_plot$mask_man[which(us_dat_plot$mask_support==4)]<-0

#Table B6
B6_ge=lm(fine_amount_w2~type2+ideology+gender+ageGroup +education+
                  political_interest+rural+covid_concern, data = ge_dat_plot)
B6_us=lm(mask_fine~type2+ideology+gender+ageGroup +education+white+
                  political_interest+rural+vaccine+covid_concern, data = us_dat_plot)
B6_hu=lm(mask_fine~type2+ideology+gender+ageGroup+education+political_interest+
                  rural+vaccine+covid_concern,data=hu_dat_plot)
B6_pl=lm(mask_fine~type2+ideology+gender+ageGroup+education+political_interest+
                  rural+vaccine+covid_concern,data=pl_dat_plot)
#Table B7

B7_ge=lm(fine_amount_w2~type2*covid_concern+ideology+gender+ageGroup +education+
           political_interest+rural+covid_concern, data = ge_dat_plot)
B7_us=lm(mask_fine~type2*covid_concern+ideology+gender+ageGroup +education+white+
           political_interest+rural+vaccine+covid_concern, data = us_dat_plot)
B7_hu=lm(mask_fine~type2*covid_concern+ideology+gender+ageGroup+education+political_interest+
           rural+vaccine+covid_concern,data=hu_dat_plot)
B7_pl=lm(mask_fine~type2*covid_concern+ideology+gender+ageGroup+education+political_interest+
           rural+vaccine+covid_concern,data=pl_dat_plot)
#Table B8
B8_ge=lm(fine_amount_w2~type2+ideology+gender+ageGroup +education+
           political_interest+rural+covid_concern+mask_man, data = ge_dat_plot)
B8_us=lm(mask_fine~type2+ideology+gender+ageGroup +education+white+
           political_interest+rural+vaccine+covid_concern+mask_man, data = us_dat_plot)
B8_hu=lm(mask_fine~type2+ideology+gender+ageGroup+education+political_interest+
           rural+vaccine+covid_concern+mask_man,data=hu_dat_plot)
B8_pl=lm(mask_fine~type2+ideology+gender+ageGroup+education+political_interest+
           rural+vaccine+covid_concern+mask_man,data=pl_dat_plot)
#Table B9

B9_ge=lm(fine_amount_w2~type2*covid_concern+ideology+gender+ageGroup +education+
           political_interest+rural+covid_concern+mask_man, data = ge_dat_plot)
B9_us=lm(mask_fine~type2*covid_concern+ideology+gender+ageGroup +education+white+
           political_interest+rural+vaccine+covid_concern+mask_man, data = us_dat_plot)
B9_hu=lm(mask_fine~type2*covid_concern+ideology+gender+ageGroup+education+political_interest+
           rural+vaccine+covid_concern+mask_man,data=hu_dat_plot)
B9_pl=lm(mask_fine~type2*covid_concern+ideology+gender+ageGroup+education+political_interest+
           rural+vaccine+covid_concern+mask_man,data=pl_dat_plot)

#Table B10
#triple interaction with consolidated binary
ge_reg<-ge_dat_plot[c("fine_amount_w2_dollars", "type2","covid_concern","ideology","gender","ageGroup","education",
                      "political_interest","rural","mask_man")]
us_reg<-us_dat_plot[c("mask_fine", "type2","covid_concern","ideology","gender","ageGroup","education",
                      "political_interest","rural","mask_man")]
hu_reg<-hu_dat_plot[c("mask_fine_dollars", "type2","covid_concern","ideology","gender","ageGroup","education",
                      "political_interest","rural","mask_man")]
pl_reg<-pl_dat_plot[c("mask_fine_dollars", "type2","covid_concern","ideology","gender","ageGroup","education",
                      "political_interest","rural","mask_man")]

colnames(ge_reg)<-c("mask_fine","type2","covid_concern","ideology","gender","ageGroup","education","political_interest","rural","mask_man")
colnames(us_reg)<-c("mask_fine","type2","covid_concern","ideology","gender","ageGroup","education","political_interest","rural","mask_man")
colnames(hu_reg)<-c("mask_fine","type2","covid_concern","ideology","gender","ageGroup","education","political_interest","rural","mask_man")
colnames(pl_reg)<-c("mask_fine","type2","covid_concern","ideology","gender","ageGroup","education","political_interest","rural","mask_man")

levels(ge_reg$type2)[levels(ge_reg$type2) %in% '1']<-'0'
levels(ge_reg$type2)[levels(ge_reg$type2) %in% '4']<-'1'
levels(ge_reg$type2)[levels(ge_reg$type2) %in% '5']<-'2'
levels(ge_reg$type2)[levels(ge_reg$type2) %in% '6']<-'3'

ge_reg$con_bi<-1
us_reg$con_bi<-1
hu_reg$con_bi<-0
pl_reg$con_bi<-0

tot_reg<-as.data.frame(rbind(ge_reg,us_reg,hu_reg,pl_reg))

B10<-lm(mask_fine~type2*covid_concern*con_bi+ideology+gender+ageGroup+education+political_interest+
  rural+covid_concern,data=tot_reg)

summary(B10)